{include file="head_2" title="代理修改" /}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">代理修改</div>
        <div class="layui-card-body" style="padding: 15px;">
            <form id="form" class="layui-form" action="{:url('users/edit_submit');}"  method="post" style="width:50%;">
                <input type="hidden" name='id' value="{:input('id')}"> 
                <div class="layui-form-item">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-block">
                        <input type="text" name="user" value="{$s->user}" lay-verify="required" autocomplete="off" placeholder="请输入账号" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" value="{$s->name}" lay-verify="required" autocomplete="off" placeholder="请输入姓名" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">密码</label>
                        <div class="layui-input-inline">
                            <input type="text" name="pwd" value=""  autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">密码可不填写,为原密码</div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">区域</label>
                    <div class="layui-input-block w50">
                        <select lay-filter="a_id"  name="a_id" >
                            {foreach $rs as $v } 
                            <option value="{$v.id}"{if $v.id eq $s->a_id}selected{/if}>{$v.sheng}{$v.shi}</option>
                            {/foreach}    
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">关联角色：</label>
                    <div class="layui-input-block">
                        {foreach $rules as $v } 
                        <input type="checkbox" name="rules[]" title="{$v.name}" value='{$v.id}' {in name="$v.id" value="$s->rules"}checked{/in} >
                               {/foreach} 
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">排序</label>
                        <div class="layui-input-inline">
                            <input type="number" name="sort" value="{$s->sort}" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">值大靠前</div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
                        <button type="button" class="layui-btn layui-btn-primary" onclick="javascript:history.back(-1)">返回</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="{$Think.const.admin_tpl}/layui/layui.js"></script>  
<script>
    layui.config({
        base: '{$Think.const.admin_tpl}/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'laydate'], function () {
        var $ = layui.$
                , layer = layui.layer
                , form = layui.form;
                
        /* 监听提交 */
        form.on('submit(sub)', function (data) {
            $.ajax({
                url: "/admin/users/dledit/",
                type: 'post',
                data: $("#form").serialize(),
                dataType: 'json',
                success: function (data) {
                    if (data.status == 1)
                    {
                        layer.confirm('操作成功！请选择？', {
                            btn: ['返回列表'] //按钮
                        }, function () {
                            location.href = '/admin/users/dlbrowse.html';
                        });
                    }
                    else
                    {
                        layer.msg(data.msg);
                    }
                },
                error: function (msg) {
                    alert(" 数据保存失败！" + msg);
                }
            });
            return false;
        });
    });
</script>
</body>
</html>